package com.example.softwareconfigurationcoursedesign;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DatabaseUtil {
    public static Connection getCon(String dbDri, String dbUrl, String username, String pass) {
        Connection connection = null;
        try {
            Class.forName(dbDri);
        } catch (ClassNotFoundException e) {
            System.err.println("无法找到数据库");
        }
        try {
            connection = DriverManager.getConnection(dbUrl, username, pass);
        } catch (SQLException throwable) {
            System.err.println("无法连接");
        }
        return connection;
    }
}
